FROM php:7.4-fpm

# https://hub.docker.com/_/php
RUN apt-get update && apt-get install -y libmemcached-dev zlib1g-dev \
    && pecl install memcached-3.1.5 \
    && pecl install redis-5.2.2 \
    && pecl install mongodb-1.7.4 \
    && docker-php-ext-enable memcached redis mongodb 

# https://developer.aliyun.com/composer?spm=a2c6h.13651102.0.0.3e221b11AuEORC
RUN curl -L https://mirrors.aliyun.com/composer/composer.phar -o /usr/local/bin/composer \
    && chmod u+x /usr/local/bin/composer \
    && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
    
# https://github.com/mlocati/docker-php-extension-installer
ADD ./docker/install-php-extensions /usr/local/bin/

RUN chmod uga+x /usr/local/bin/install-php-extensions && sync && \
    install-php-extensions bcmath gd mysqli zip pdo_mysql

# copy应用目录和nginx配置
ADD --chown=www-data:www-data ./ /usr/share/nginx/html/
ADD ./docker/conf/nginx/conf.d/ /etc/nginx/conf.d/
